<?php


namespace app\voip\controller;


use app\voip\func\AirlinesLogFunc;
use app\voip\func\CallTaskFunc;
use vae\controller\AdminCheckAuth;

class TaskStatController extends AdminCheckAuth
{
    public function taskLog()
    {
        $where=[];
        $where['c1.aid']=vae_get_login_admin('id');

        return view('',['taskList'=>CallTaskFunc::getOptionList($where)]);
    }
    /**
     * @param $keywords
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function ajaxLogList($keywords='')
    {
        try{
            $validate=validate('AirlinesAuth');
            if (!$validate->scene(__FUNCTION__)->check($keywords)){
                throw new \Exception($validate->getError());
            }
            $where=[];
            if (!empty($keywords['datetime'])){
                $datetime=explode(' - ',$keywords['datetime']);
                $where['a1.create_time']=array(array('gt',strtotime($datetime[0])),array('lt',strtotime("+1 day",strtotime($datetime[1]))));
            }

            $where['a1.tid']=$keywords['tid'];

            $order="a1.id ";
            $orderAsc='asc';
            if ($keywords['order']==2){
                $orderAsc='desc';
            }
            switch ($keywords['orderType']){
                case 1:
                    $order="a1.intention ";
                    break;
                case 2:
                    $order="a1.mark ";
                    break;
            }
        }catch (\Exception $e){
            return vae_assign(0,'',[]);
        }
        $orderWhere=$order.$orderAsc;

        $result=AirlinesLogFunc::aLoginList($where,$orderWhere);
        return vae_assign(0,'',$result);

    }
}